package com.chey.service.impl;

import com.chey.dao.GtlsDao;
import com.chey.pojo.META;
import com.chey.pojo.gtls.DFLT;
import com.chey.pojo.gtls.GATE;
import com.chey.pojo.gtls.MSG18;
import com.chey.service.GtlsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author JanYao
 * @version 0.1
 */
@Service
public class GtlsServiceImpl implements GtlsService {
    @Autowired
    private GtlsDao gtlsDao;
    @Override
    public void insert(MSG18 msg) {

        String ftls_uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();

        META meta = msg.getMeta();
        DFLT dflt = msg.getDFLT();
        gtlsDao.addGtls(ftls_uuid,meta,dflt);
        List<GATE> gates = dflt.getGATE();
        for (GATE gate :gates) {
            gtlsDao.addGate(ftls_uuid,gate);

        }


    }
}
